package com.cbd.pojo;

import java.io.Serializable;
import java.util.*;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.validation.annotation.Validated;

/**
 * 操作员
 * 
 */
@Entity
@Table(name="operator")
@Validated
public class Operator implements Serializable{
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="operatorID")
	private int operatorID;
	/**
	 * 操作员姓名
	 * 
	 */
	@Column(name="operatorName")
	@NotEmpty(message="不能为空")
	@Length(max=10,min=2,message="长度必须为2-10位")
	private String operatorName;
	/**
	 * 操作员电话
	 * 
	 */
	@Column(name="operatorTel")
	@NotEmpty(message="不能为空")
	@Length(max=11,min=11,message="长度必须为11-11位")
	private String operatorTel;

	/**
	 * 操作员级别
	 */
	@ManyToMany(cascade = {CascadeType.ALL})
	@JoinTable(name="operatorlevel",
				joinColumns=@JoinColumn(name="operatorID"),
				inverseJoinColumns=@JoinColumn(name="levelID")
			)
	private List<Level> levels;
	@OneToOne(cascade=CascadeType.ALL)
	@JoinColumn(name="userID")
	private User user;

	public int getOperatorID() {
		return operatorID;
	}

	public void setOperatorID(int operatorID) {
		this.operatorID = operatorID;
	}

	public String getOperatorName() {
		return operatorName;
	}

	public void setOperatorName(String operatorName) {
		this.operatorName = operatorName;
	}

	public String getOperatorTel() {
		return operatorTel;
	}

	public void setOperatorTel(String operatorTel) {
		this.operatorTel = operatorTel;
	}

	public List<Level> getLevels() {
		return levels;
	}

	public void setLevels(List<Level> levels) {
		this.levels = levels;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
	
}